package interfaces;

import org.fenggui.binding.render.ITexture;
import org.fenggui.binding.render.Pixmap;
import org.fenggui.decorator.background.PixmapBackground;

import interfaces.superWidgets.StaticContent;

public class ImageUpdater extends StaticContent {
	
	public ImageUpdater(String defaultImagePath, int x, int y, int width, int height) {
		super(width, height, x, y);
		setImage(defaultImagePath);
	}
	
	public ImageUpdater(int x, int y, int width, int height) {
		super(width, height, x, y);
	}
	
	public void setImage(String defaultImagePath) {
		getAppearance().removeAll();
		ITexture texture = GUISource.loadTexture(defaultImagePath);
		if(texture == null) return;
		Pixmap pixmap = new Pixmap(texture);
		getAppearance().add(new PixmapBackground(pixmap, true));
	}
}